package com.wanshu.controller;


import com.alibaba.fastjson.JSON;
import com.wanshu.entity.Shop;
import com.wanshu.service.ShopService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@CrossOrigin("http://localhost:8080")
@RequestMapping("/shop")
public class ShopController {

    @Resource
    ShopService shopService;

    @GetMapping("/findAll")
    public String findAll(){
        List<Shop> all = shopService.findAll();
        System.out.println(all);
        return JSON.toJSONString(all);
    }

    @RequestMapping("/findById")
    public String findById(Integer id){
        Shop byId = shopService.findById(id);
        System.out.println(byId);
        return JSON.toJSONString(byId);
    }
}
